package org.budo.weixin.api.response;

import java.io.Serializable;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;

/**
 * @author limingwei
 */
@Slf4j
@Getter
@Setter
@Accessors(chain = true)
@ToString
public class SendMessageResponse implements Serializable {
    private static final long serialVersionUID = 4873515362994632008L;

    private String responseBody;

    /*
     * {"errcode":40001,
     * "errmsg":"invalid credential, access_token is invalid or not latest hints: [jjFdn2Dae-LHVH8a!]"
     * }
     */
    public Boolean isOk() {
        if (null == this.responseBody) {
            log.error("#29 isOk return false, this=" + this);
            return false;
        }

        if (this.responseBody.contains("invalid credential, access_token is invalid or not latest hints")) {
            log.error("#36 isOk return false, this=" + this);
            return false;
        }

        return true;
    }
}